package com.dura.test;

import com.dura.test.client.CacheClient;
import com.dura.test.mapper.MobileBlackMapper;
import com.dura.test.pojo.MobileBlack;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

import static org.junit.jupiter.api.Assertions.*;

/**
 * @version 1.0
 * @Author 振鹏
 * @Date 2025/3/17 8:33
 * @注释
 */
@SpringBootTest
@RunWith(SpringRunner.class)
class MobileBlackMapperTest {
    @Autowired
    private MobileBlackMapper mapper;

    @Autowired
    private CacheClient cacheClient;

    @Test
    void findNumber() {
        List<MobileBlack> number = mapper.findNumber();
        System.out.println(number.get(0).getBlackNumber());

        for (MobileBlack mobileBlack : number) {

            if(mobileBlack.getClientId()==0){
                // 全局的黑名单   black:手机号   作为key
                cacheClient.set("black:" + mobileBlack.getBlackNumber(),"1");
            }else{
                // black:手机号  如果是客户黑名单
                cacheClient.set("black:"+mobileBlack.getClientId()+":" + mobileBlack.getBlackNumber(),"1");
            }
        }
    }
}